﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using GPSTrackingDBV2.Entities;
using GPSTrackingDBV2.Data;

#endregion

namespace GPSTrackingDBV2.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="GpsStockProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class GpsStockProviderBaseCore : EntityProviderBase<GPSTrackingDBV2.Entities.GpsStock, GPSTrackingDBV2.Entities.GpsStockKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByGeoFenceIdFromGeoFencesByGpsStock
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by GeoFenceID in the
		///		GeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the GeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_geoFenceId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromGeoFencesByGpsStock(System.Int32 _geoFenceId)
		{
			int count = -1;
			return GetByGeoFenceIdFromGeoFencesByGpsStock(null,_geoFenceId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by GeoFenceID in the
		///		GeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the GeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromGeoFencesByGpsStock(System.Int32 _geoFenceId, int start, int pageLength)
		{
			int count = -1;
			return GetByGeoFenceIdFromGeoFencesByGpsStock(null, _geoFenceId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GeoFenceID in the
		///		GeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the GeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _geoFenceId)
		{
			int count = -1;
			return GetByGeoFenceIdFromGeoFencesByGpsStock(transactionManager, _geoFenceId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GeoFenceID in the
		///		GeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the GeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_geoFenceId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _geoFenceId,int start, int pageLength)
		{
			int count = -1;
			return GetByGeoFenceIdFromGeoFencesByGpsStock(transactionManager, _geoFenceId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GeoFenceID in the
		///		GeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the GeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_geoFenceId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromGeoFencesByGpsStock(System.Int32 _geoFenceId,int start, int pageLength, out int count)
		{
			
			return GetByGeoFenceIdFromGeoFencesByGpsStock(null, _geoFenceId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by GeoFenceID in the
		///		GeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the GeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByGeoFenceIdFromGeoFencesByGpsStock(TransactionManager transactionManager,System.Int32 _geoFenceId, int start, int pageLength, out int count);
		
		#endregion GetByGeoFenceIdFromGeoFencesByGpsStock
		
		#region GetByGpsGroupIdFromGpsStockByGpsGroups
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by GPSGroupID in the
		///		GPSStockByGPSGroups table. Table GPSStock is related to table GPSGroups
		///		through the (M:N) relationship defined in the GPSStockByGPSGroups table.
		/// </summary>
		/// <param name="_gpsGroupId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsGroupIdFromGpsStockByGpsGroups(System.Int32 _gpsGroupId)
		{
			int count = -1;
			return GetByGpsGroupIdFromGpsStockByGpsGroups(null,_gpsGroupId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by GPSGroupID in the
		///		GPSStockByGPSGroups table. Table GPSStock is related to table GPSGroups
		///		through the (M:N) relationship defined in the GPSStockByGPSGroups table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsGroupIdFromGpsStockByGpsGroups(System.Int32 _gpsGroupId, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsGroupIdFromGpsStockByGpsGroups(null, _gpsGroupId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GPSGroupID in the
		///		GPSStockByGPSGroups table. Table GPSStock is related to table GPSGroups
		///		through the (M:N) relationship defined in the GPSStockByGPSGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGpsGroupIdFromGpsStockByGpsGroups(TransactionManager transactionManager, System.Int32 _gpsGroupId)
		{
			int count = -1;
			return GetByGpsGroupIdFromGpsStockByGpsGroups(transactionManager, _gpsGroupId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GPSGroupID in the
		///		GPSStockByGPSGroups table. Table GPSStock is related to table GPSGroups
		///		through the (M:N) relationship defined in the GPSStockByGPSGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsGroupId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGpsGroupIdFromGpsStockByGpsGroups(TransactionManager transactionManager, System.Int32 _gpsGroupId,int start, int pageLength)
		{
			int count = -1;
			return GetByGpsGroupIdFromGpsStockByGpsGroups(transactionManager, _gpsGroupId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GPSGroupID in the
		///		GPSStockByGPSGroups table. Table GPSStock is related to table GPSGroups
		///		through the (M:N) relationship defined in the GPSStockByGPSGroups table.
		/// </summary>
		/// <param name="_gpsGroupId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGpsGroupIdFromGpsStockByGpsGroups(System.Int32 _gpsGroupId,int start, int pageLength, out int count)
		{
			
			return GetByGpsGroupIdFromGpsStockByGpsGroups(null, _gpsGroupId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by GPSGroupID in the
		///		GPSStockByGPSGroups table. Table GPSStock is related to table GPSGroups
		///		through the (M:N) relationship defined in the GPSStockByGPSGroups table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_gpsGroupId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByGpsGroupIdFromGpsStockByGpsGroups(TransactionManager transactionManager,System.Int32 _gpsGroupId, int start, int pageLength, out int count);
		
		#endregion GetByGpsGroupIdFromGpsStockByGpsGroups
		
		#region GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_geoFenceId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(System.Int32 _geoFenceId)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(null,_geoFenceId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(System.Int32 _geoFenceId, int start, int pageLength)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(null, _geoFenceId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _geoFenceId)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(transactionManager, _geoFenceId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_geoFenceId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _geoFenceId,int start, int pageLength)
		{
			int count = -1;
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(transactionManager, _geoFenceId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_geoFenceId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(System.Int32 _geoFenceId,int start, int pageLength, out int count)
		{
			
			return GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(null, _geoFenceId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by GeoFenceID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table GeoFences
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_geoFenceId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager,System.Int32 _geoFenceId, int start, int pageLength, out int count);
		
		#endregion GetByGeoFenceIdFromNotificationByGeoFencesByGpsStock
		
		#region GetByNotificationIdFromNotificationByGeoFencesByGpsStock
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_notificationId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(System.Int32 _notificationId)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(null,_notificationId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(System.Int32 _notificationId, int start, int pageLength)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(null, _notificationId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _notificationId)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(transactionManager, _notificationId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_notificationId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.Int32 _notificationId,int start, int pageLength)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(transactionManager, _notificationId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_notificationId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(System.Int32 _notificationId,int start, int pageLength, out int count)
		{
			
			return GetByNotificationIdFromNotificationByGeoFencesByGpsStock(null, _notificationId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by NotificationID in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByNotificationIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager,System.Int32 _notificationId, int start, int pageLength, out int count);
		
		#endregion GetByNotificationIdFromNotificationByGeoFencesByGpsStock
		
		#region GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by Username in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(System.String _username, System.Int32 _companyId)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(null,_username, _companyId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by Username in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(System.String _username, System.Int32 _companyId, int start, int pageLength)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(null, _username, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by Username in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.String _username, System.Int32 _companyId)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(transactionManager, _username, _companyId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by Username in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager, System.String _username, System.Int32 _companyId,int start, int pageLength)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(transactionManager, _username, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by Username in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(System.String _username, System.Int32 _companyId,int start, int pageLength, out int count)
		{
			
			return GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(null, _username, _companyId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by Username in the
		///		NotificationByGeoFencesByGPSStock table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the NotificationByGeoFencesByGPSStock table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock(TransactionManager transactionManager,System.String _username, System.Int32 _companyId, int start, int pageLength, out int count);
		
		#endregion GetByUsernameCompanyIdFromNotificationByGeoFencesByGpsStock
		
		#region GetByNotificationIdFromNotificationsByGps
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by NotificationID in the
		///		NotificationsByGPS table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationsByGPS table.
		/// </summary>
		/// <param name="_notificationId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationsByGps(System.Int32 _notificationId)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationsByGps(null,_notificationId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by NotificationID in the
		///		NotificationsByGPS table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationsByGPS table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationsByGps(System.Int32 _notificationId, int start, int pageLength)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationsByGps(null, _notificationId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by NotificationID in the
		///		NotificationsByGPS table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationsByGPS table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationsByGps(TransactionManager transactionManager, System.Int32 _notificationId)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationsByGps(transactionManager, _notificationId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by NotificationID in the
		///		NotificationsByGPS table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationsByGPS table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_notificationId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationsByGps(TransactionManager transactionManager, System.Int32 _notificationId,int start, int pageLength)
		{
			int count = -1;
			return GetByNotificationIdFromNotificationsByGps(transactionManager, _notificationId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by NotificationID in the
		///		NotificationsByGPS table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationsByGPS table.
		/// </summary>
		/// <param name="_notificationId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByNotificationIdFromNotificationsByGps(System.Int32 _notificationId,int start, int pageLength, out int count)
		{
			
			return GetByNotificationIdFromNotificationsByGps(null, _notificationId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by NotificationID in the
		///		NotificationsByGPS table. Table GPSStock is related to table Notifications
		///		through the (M:N) relationship defined in the NotificationsByGPS table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_notificationId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByNotificationIdFromNotificationsByGps(TransactionManager transactionManager,System.Int32 _notificationId, int start, int pageLength, out int count);
		
		#endregion GetByNotificationIdFromNotificationsByGps
		
		#region GetByUsernameCompanyIdFromUsersByGpsStocks
		
		/// <summary>
		///		Gets GPSStock objects from the datasource by Username in the
		///		UsersByGPSStocks table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <returns>Returns a typed collection of GpsStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromUsersByGpsStocks(System.String _username, System.Int32 _companyId)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromUsersByGpsStocks(null,_username, _companyId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets GPSTrackingDBV2.Entities.GpsStock objects from the datasource by Username in the
		///		UsersByGPSStocks table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromUsersByGpsStocks(System.String _username, System.Int32 _companyId, int start, int pageLength)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromUsersByGpsStocks(null, _username, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by Username in the
		///		UsersByGPSStocks table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromUsersByGpsStocks(TransactionManager transactionManager, System.String _username, System.Int32 _companyId)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromUsersByGpsStocks(transactionManager, _username, _companyId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by Username in the
		///		UsersByGPSStocks table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromUsersByGpsStocks(TransactionManager transactionManager, System.String _username, System.Int32 _companyId,int start, int pageLength)
		{
			int count = -1;
			return GetByUsernameCompanyIdFromUsersByGpsStocks(transactionManager, _username, _companyId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets GpsStock objects from the datasource by Username in the
		///		UsersByGPSStocks table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSStock objects.</returns>
		public TList<GpsStock> GetByUsernameCompanyIdFromUsersByGpsStocks(System.String _username, System.Int32 _companyId,int start, int pageLength, out int count)
		{
			
			return GetByUsernameCompanyIdFromUsersByGpsStocks(null, _username, _companyId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets GPSStock objects from the datasource by Username in the
		///		UsersByGPSStocks table. Table GPSStock is related to table Users
		///		through the (M:N) relationship defined in the UsersByGPSStocks table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_username"></param>
		/// <param name="_companyId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByUsernameCompanyIdFromUsersByGpsStocks(TransactionManager transactionManager,System.String _username, System.Int32 _companyId, int start, int pageLength, out int count);
		
		#endregion GetByUsernameCompanyIdFromUsersByGpsStocks
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, GPSTrackingDBV2.Entities.GpsStockKey key)
		{
			return Delete(transactionManager, key.GpsImei);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_gpsImei">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.String _gpsImei)
		{
			return Delete(null, _gpsImei);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.String _gpsImei);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSModels key.
		///		FK_GPSStock_GPSModels Description: 
		/// </summary>
		/// <param name="_gpsModelId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsModelId(System.Int32 _gpsModelId)
		{
			int count = -1;
			return GetByGpsModelId(_gpsModelId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSModels key.
		///		FK_GPSStock_GPSModels Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsModelId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		/// <remarks></remarks>
		public TList<GpsStock> GetByGpsModelId(TransactionManager transactionManager, System.Int32 _gpsModelId)
		{
			int count = -1;
			return GetByGpsModelId(transactionManager, _gpsModelId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSModels key.
		///		FK_GPSStock_GPSModels Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsModelId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsModelId(TransactionManager transactionManager, System.Int32 _gpsModelId, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsModelId(transactionManager, _gpsModelId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSModels key.
		///		fkGpsStockGpsModels Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsModelId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsModelId(System.Int32 _gpsModelId, int start, int pageLength)
		{
			int count =  -1;
			return GetByGpsModelId(null, _gpsModelId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSModels key.
		///		fkGpsStockGpsModels Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsModelId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsModelId(System.Int32 _gpsModelId, int start, int pageLength,out int count)
		{
			return GetByGpsModelId(null, _gpsModelId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSModels key.
		///		FK_GPSStock_GPSModels Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsModelId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByGpsModelId(TransactionManager transactionManager, System.Int32 _gpsModelId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSType key.
		///		FK_GPSStock_GPSType Description: 
		/// </summary>
		/// <param name="_gpsTypeId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsTypeId(System.Int32 _gpsTypeId)
		{
			int count = -1;
			return GetByGpsTypeId(_gpsTypeId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSType key.
		///		FK_GPSStock_GPSType Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsTypeId"></param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		/// <remarks></remarks>
		public TList<GpsStock> GetByGpsTypeId(TransactionManager transactionManager, System.Int32 _gpsTypeId)
		{
			int count = -1;
			return GetByGpsTypeId(transactionManager, _gpsTypeId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSType key.
		///		FK_GPSStock_GPSType Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsTypeId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsTypeId(TransactionManager transactionManager, System.Int32 _gpsTypeId, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsTypeId(transactionManager, _gpsTypeId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSType key.
		///		fkGpsStockGpsType Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsTypeId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsTypeId(System.Int32 _gpsTypeId, int start, int pageLength)
		{
			int count =  -1;
			return GetByGpsTypeId(null, _gpsTypeId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSType key.
		///		fkGpsStockGpsType Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gpsTypeId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public TList<GpsStock> GetByGpsTypeId(System.Int32 _gpsTypeId, int start, int pageLength,out int count)
		{
			return GetByGpsTypeId(null, _gpsTypeId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_GPSStock_GPSType key.
		///		FK_GPSStock_GPSType Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsTypeId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of GPSTrackingDBV2.Entities.GpsStock objects.</returns>
		public abstract TList<GpsStock> GetByGpsTypeId(TransactionManager transactionManager, System.Int32 _gpsTypeId, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override GPSTrackingDBV2.Entities.GpsStock Get(TransactionManager transactionManager, GPSTrackingDBV2.Entities.GpsStockKey key, int start, int pageLength)
		{
			return GetByGpsImei(transactionManager, key.GpsImei, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_GPSStock_1 index.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> class.</returns>
		public GPSTrackingDBV2.Entities.GpsStock GetByGpsImei(System.String _gpsImei)
		{
			int count = -1;
			return GetByGpsImei(null,_gpsImei, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_GPSStock_1 index.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> class.</returns>
		public GPSTrackingDBV2.Entities.GpsStock GetByGpsImei(System.String _gpsImei, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsImei(null, _gpsImei, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_GPSStock_1 index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> class.</returns>
		public GPSTrackingDBV2.Entities.GpsStock GetByGpsImei(TransactionManager transactionManager, System.String _gpsImei)
		{
			int count = -1;
			return GetByGpsImei(transactionManager, _gpsImei, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_GPSStock_1 index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> class.</returns>
		public GPSTrackingDBV2.Entities.GpsStock GetByGpsImei(TransactionManager transactionManager, System.String _gpsImei, int start, int pageLength)
		{
			int count = -1;
			return GetByGpsImei(transactionManager, _gpsImei, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_GPSStock_1 index.
		/// </summary>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> class.</returns>
		public GPSTrackingDBV2.Entities.GpsStock GetByGpsImei(System.String _gpsImei, int start, int pageLength, out int count)
		{
			return GetByGpsImei(null, _gpsImei, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_GPSStock_1 index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gpsImei"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> class.</returns>
		public abstract GPSTrackingDBV2.Entities.GpsStock GetByGpsImei(TransactionManager transactionManager, System.String _gpsImei, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;GpsStock&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;GpsStock&gt;"/></returns>
		public static TList<GpsStock> Fill(IDataReader reader, TList<GpsStock> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				GPSTrackingDBV2.Entities.GpsStock c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("GpsStock")
					.Append("|").Append((System.String)reader[((int)GpsStockColumn.GpsImei - 1)]).ToString();
					c = EntityManager.LocateOrCreate<GpsStock>(
					key.ToString(), // EntityTrackingKey
					"GpsStock",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new GPSTrackingDBV2.Entities.GpsStock();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.GpsImei = (System.String)reader[((int)GpsStockColumn.GpsImei - 1)];
					c.OriginalGpsImei = c.GpsImei;
					c.Name = (System.String)reader[((int)GpsStockColumn.Name - 1)];
					c.SimNumber = (System.String)reader[((int)GpsStockColumn.SimNumber - 1)];
					c.Description = (reader.IsDBNull(((int)GpsStockColumn.Description - 1)))?null:(System.String)reader[((int)GpsStockColumn.Description - 1)];
					c.GpsTypeId = (System.Int32)reader[((int)GpsStockColumn.GpsTypeId - 1)];
					c.GpsModelId = (System.Int32)reader[((int)GpsStockColumn.GpsModelId - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.GpsStock"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, GPSTrackingDBV2.Entities.GpsStock entity)
		{
			if (!reader.Read()) return;
			
			entity.GpsImei = (System.String)reader[((int)GpsStockColumn.GpsImei - 1)];
			entity.OriginalGpsImei = (System.String)reader["GPSImei"];
			entity.Name = (System.String)reader[((int)GpsStockColumn.Name - 1)];
			entity.SimNumber = (System.String)reader[((int)GpsStockColumn.SimNumber - 1)];
			entity.Description = (reader.IsDBNull(((int)GpsStockColumn.Description - 1)))?null:(System.String)reader[((int)GpsStockColumn.Description - 1)];
			entity.GpsTypeId = (System.Int32)reader[((int)GpsStockColumn.GpsTypeId - 1)];
			entity.GpsModelId = (System.Int32)reader[((int)GpsStockColumn.GpsModelId - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="GPSTrackingDBV2.Entities.GpsStock"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.GpsStock"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, GPSTrackingDBV2.Entities.GpsStock entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.GpsImei = (System.String)dataRow["GPSImei"];
			entity.OriginalGpsImei = (System.String)dataRow["GPSImei"];
			entity.Name = (System.String)dataRow["Name"];
			entity.SimNumber = (System.String)dataRow["SimNumber"];
			entity.Description = Convert.IsDBNull(dataRow["Description"]) ? null : (System.String)dataRow["Description"];
			entity.GpsTypeId = (System.Int32)dataRow["GPSTypeID"];
			entity.GpsModelId = (System.Int32)dataRow["GPSModelID"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="GPSTrackingDBV2.Entities.GpsStock"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">GPSTrackingDBV2.Entities.GpsStock Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, GPSTrackingDBV2.Entities.GpsStock entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region GpsModelIdSource	
			if (CanDeepLoad(entity, "GpsModels|GpsModelIdSource", deepLoadType, innerList) 
				&& entity.GpsModelIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.GpsModelId;
				GpsModels tmpEntity = EntityManager.LocateEntity<GpsModels>(EntityLocator.ConstructKeyFromPkItems(typeof(GpsModels), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.GpsModelIdSource = tmpEntity;
				else
					entity.GpsModelIdSource = DataRepository.GpsModelsProvider.GetByGpsModelId(transactionManager, entity.GpsModelId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsModelIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GpsModelIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.GpsModelsProvider.DeepLoad(transactionManager, entity.GpsModelIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion GpsModelIdSource

			#region GpsTypeIdSource	
			if (CanDeepLoad(entity, "GpsType|GpsTypeIdSource", deepLoadType, innerList) 
				&& entity.GpsTypeIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.GpsTypeId;
				GpsType tmpEntity = EntityManager.LocateEntity<GpsType>(EntityLocator.ConstructKeyFromPkItems(typeof(GpsType), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.GpsTypeIdSource = tmpEntity;
				else
					entity.GpsTypeIdSource = DataRepository.GpsTypeProvider.GetByGpsTypeId(transactionManager, entity.GpsTypeId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsTypeIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GpsTypeIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.GpsTypeProvider.DeepLoad(transactionManager, entity.GpsTypeIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion GpsTypeIdSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByGpsImei methods when available
			
			#region ClientsToVisitCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<ClientsToVisit>|ClientsToVisitCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'ClientsToVisitCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.ClientsToVisitCollection = DataRepository.ClientsToVisitProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.ClientsToVisitCollection.Count > 0)
				{
					deepHandles.Add("ClientsToVisitCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<ClientsToVisit>) DataRepository.ClientsToVisitProvider.DeepLoad,
						new object[] { transactionManager, entity.ClientsToVisitCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GeoFences>|GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock = DataRepository.GeoFencesProvider.GetByGpsImeiFromGeoFencesByGpsStock(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock != null)
				{
					deepHandles.Add("GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GeoFences >) DataRepository.GeoFencesProvider.DeepLoad,
						new object[] { transactionManager, entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region UsersByGpsStocksCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<UsersByGpsStocks>|UsersByGpsStocksCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsersByGpsStocksCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.UsersByGpsStocksCollection = DataRepository.UsersByGpsStocksProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.UsersByGpsStocksCollection.Count > 0)
				{
					deepHandles.Add("UsersByGpsStocksCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<UsersByGpsStocks>) DataRepository.UsersByGpsStocksProvider.DeepLoad,
						new object[] { transactionManager, entity.UsersByGpsStocksCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GpsGroups>|GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups", deepLoadType, innerList))
			{
				entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups = DataRepository.GpsGroupsProvider.GetByGpsImeiFromGpsStockByGpsGroups(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups != null)
				{
					deepHandles.Add("GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GpsGroups >) DataRepository.GpsGroupsProvider.DeepLoad,
						new object[] { transactionManager, entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Notifications>|NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock = DataRepository.NotificationsProvider.GetByGpsImeiFromNotificationByGeoFencesByGpsStock(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock != null)
				{
					deepHandles.Add("NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Notifications >) DataRepository.NotificationsProvider.DeepLoad,
						new object[] { transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region GpsStockByGpsGroupsCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<GpsStockByGpsGroups>|GpsStockByGpsGroupsCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GpsStockByGpsGroupsCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.GpsStockByGpsGroupsCollection = DataRepository.GpsStockByGpsGroupsProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.GpsStockByGpsGroupsCollection.Count > 0)
				{
					deepHandles.Add("GpsStockByGpsGroupsCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<GpsStockByGpsGroups>) DataRepository.GpsStockByGpsGroupsProvider.DeepLoad,
						new object[] { transactionManager, entity.GpsStockByGpsGroupsCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region GeoFencesByGpsStockCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<GeoFencesByGpsStock>|GeoFencesByGpsStockCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GeoFencesByGpsStockCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.GeoFencesByGpsStockCollection = DataRepository.GeoFencesByGpsStockProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.GeoFencesByGpsStockCollection.Count > 0)
				{
					deepHandles.Add("GeoFencesByGpsStockCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<GeoFencesByGpsStock>) DataRepository.GeoFencesByGpsStockProvider.DeepLoad,
						new object[] { transactionManager, entity.GeoFencesByGpsStockCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Users>|UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock = DataRepository.UsersProvider.GetByGpsImeiFromNotificationByGeoFencesByGpsStock(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock != null)
				{
					deepHandles.Add("UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Users >) DataRepository.UsersProvider.DeepLoad,
						new object[] { transactionManager, entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NotificationIdNotificationsCollection_From_NotificationsByGps
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Notifications>|NotificationIdNotificationsCollection_From_NotificationsByGps", deepLoadType, innerList))
			{
				entity.NotificationIdNotificationsCollection_From_NotificationsByGps = DataRepository.NotificationsProvider.GetByGpsImeiFromNotificationsByGps(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NotificationIdNotificationsCollection_From_NotificationsByGps' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.NotificationIdNotificationsCollection_From_NotificationsByGps != null)
				{
					deepHandles.Add("NotificationIdNotificationsCollection_From_NotificationsByGps",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Notifications >) DataRepository.NotificationsProvider.DeepLoad,
						new object[] { transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationsByGps, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region RoutesCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<Routes>|RoutesCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'RoutesCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.RoutesCollection = DataRepository.RoutesProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.RoutesCollection.Count > 0)
				{
					deepHandles.Add("RoutesCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<Routes>) DataRepository.RoutesProvider.DeepLoad,
						new object[] { transactionManager, entity.RoutesCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region NotificationsByGpsCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NotificationsByGps>|NotificationsByGpsCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NotificationsByGpsCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NotificationsByGpsCollection = DataRepository.NotificationsByGpsProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.NotificationsByGpsCollection.Count > 0)
				{
					deepHandles.Add("NotificationsByGpsCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NotificationsByGps>) DataRepository.NotificationsByGpsProvider.DeepLoad,
						new object[] { transactionManager, entity.NotificationsByGpsCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<GeoFences>|GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock", deepLoadType, innerList))
			{
				entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock = DataRepository.GeoFencesProvider.GetByGpsImeiFromNotificationByGeoFencesByGpsStock(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock != null)
				{
					deepHandles.Add("GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< GeoFences >) DataRepository.GeoFencesProvider.DeepLoad,
						new object[] { transactionManager, entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region UsernameCompanyIdUsersCollection_From_UsersByGpsStocks
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<Users>|UsernameCompanyIdUsersCollection_From_UsersByGpsStocks", deepLoadType, innerList))
			{
				entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks = DataRepository.UsersProvider.GetByGpsImeiFromUsersByGpsStocks(transactionManager, entity.GpsImei);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UsernameCompanyIdUsersCollection_From_UsersByGpsStocks' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks != null)
				{
					deepHandles.Add("UsernameCompanyIdUsersCollection_From_UsersByGpsStocks",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< Users >) DataRepository.UsersProvider.DeepLoad,
						new object[] { transactionManager, entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			#region NotificationByGeoFencesByGpsStockCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<NotificationByGeoFencesByGpsStock>|NotificationByGeoFencesByGpsStockCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'NotificationByGeoFencesByGpsStockCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.NotificationByGeoFencesByGpsStockCollection = DataRepository.NotificationByGeoFencesByGpsStockProvider.GetByGpsImei(transactionManager, entity.GpsImei);

				if (deep && entity.NotificationByGeoFencesByGpsStockCollection.Count > 0)
				{
					deepHandles.Add("NotificationByGeoFencesByGpsStockCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<NotificationByGeoFencesByGpsStock>) DataRepository.NotificationByGeoFencesByGpsStockProvider.DeepLoad,
						new object[] { transactionManager, entity.NotificationByGeoFencesByGpsStockCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the GPSTrackingDBV2.Entities.GpsStock object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">GPSTrackingDBV2.Entities.GpsStock instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">GPSTrackingDBV2.Entities.GpsStock Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, GPSTrackingDBV2.Entities.GpsStock entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region GpsModelIdSource
			if (CanDeepSave(entity, "GpsModels|GpsModelIdSource", deepSaveType, innerList) 
				&& entity.GpsModelIdSource != null)
			{
				DataRepository.GpsModelsProvider.Save(transactionManager, entity.GpsModelIdSource);
				entity.GpsModelId = entity.GpsModelIdSource.GpsModelId;
			}
			#endregion 
			
			#region GpsTypeIdSource
			if (CanDeepSave(entity, "GpsType|GpsTypeIdSource", deepSaveType, innerList) 
				&& entity.GpsTypeIdSource != null)
			{
				DataRepository.GpsTypeProvider.Save(transactionManager, entity.GpsTypeIdSource);
				entity.GpsTypeId = entity.GpsTypeIdSource.GpsTypeId;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock>
			if (CanDeepSave(entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock, "List<GeoFences>|GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock.Count > 0 || entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.GeoFencesProvider.Save(transactionManager, entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock); 
					deepHandles.Add("GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GeoFences>) DataRepository.GeoFencesProvider.DeepSave,
						new object[] { transactionManager, entity.GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups>
			if (CanDeepSave(entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups, "List<GpsGroups>|GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups", deepSaveType, innerList))
			{
				if (entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups.Count > 0 || entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups.DeletedItems.Count > 0)
				{
					DataRepository.GpsGroupsProvider.Save(transactionManager, entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups); 
					deepHandles.Add("GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GpsGroups>) DataRepository.GpsGroupsProvider.DeepSave,
						new object[] { transactionManager, entity.GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock>
			if (CanDeepSave(entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock, "List<Notifications>|NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock.Count > 0 || entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.NotificationsProvider.Save(transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock); 
					deepHandles.Add("NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Notifications>) DataRepository.NotificationsProvider.DeepSave,
						new object[] { transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock>
			if (CanDeepSave(entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock, "List<Users>|UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock.Count > 0 || entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.UsersProvider.Save(transactionManager, entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock); 
					deepHandles.Add("UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Users>) DataRepository.UsersProvider.DeepSave,
						new object[] { transactionManager, entity.UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region NotificationIdNotificationsCollection_From_NotificationsByGps>
			if (CanDeepSave(entity.NotificationIdNotificationsCollection_From_NotificationsByGps, "List<Notifications>|NotificationIdNotificationsCollection_From_NotificationsByGps", deepSaveType, innerList))
			{
				if (entity.NotificationIdNotificationsCollection_From_NotificationsByGps.Count > 0 || entity.NotificationIdNotificationsCollection_From_NotificationsByGps.DeletedItems.Count > 0)
				{
					DataRepository.NotificationsProvider.Save(transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationsByGps); 
					deepHandles.Add("NotificationIdNotificationsCollection_From_NotificationsByGps",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Notifications>) DataRepository.NotificationsProvider.DeepSave,
						new object[] { transactionManager, entity.NotificationIdNotificationsCollection_From_NotificationsByGps, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock>
			if (CanDeepSave(entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock, "List<GeoFences>|GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock", deepSaveType, innerList))
			{
				if (entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock.Count > 0 || entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock.DeletedItems.Count > 0)
				{
					DataRepository.GeoFencesProvider.Save(transactionManager, entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock); 
					deepHandles.Add("GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<GeoFences>) DataRepository.GeoFencesProvider.DeepSave,
						new object[] { transactionManager, entity.GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 

			#region UsernameCompanyIdUsersCollection_From_UsersByGpsStocks>
			if (CanDeepSave(entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks, "List<Users>|UsernameCompanyIdUsersCollection_From_UsersByGpsStocks", deepSaveType, innerList))
			{
				if (entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks.Count > 0 || entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks.DeletedItems.Count > 0)
				{
					DataRepository.UsersProvider.Save(transactionManager, entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks); 
					deepHandles.Add("UsernameCompanyIdUsersCollection_From_UsersByGpsStocks",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<Users>) DataRepository.UsersProvider.DeepSave,
						new object[] { transactionManager, entity.UsernameCompanyIdUsersCollection_From_UsersByGpsStocks, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<ClientsToVisit>
				if (CanDeepSave(entity.ClientsToVisitCollection, "List<ClientsToVisit>|ClientsToVisitCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(ClientsToVisit child in entity.ClientsToVisitCollection)
					{
						if(child.GpsImeiSource != null)
						{
							child.GpsImei = child.GpsImeiSource.GpsImei;
						}
						else
						{
							child.GpsImei = entity.GpsImei;
						}

					}

					if (entity.ClientsToVisitCollection.Count > 0 || entity.ClientsToVisitCollection.DeletedItems.Count > 0)
					{
						//DataRepository.ClientsToVisitProvider.Save(transactionManager, entity.ClientsToVisitCollection);
						
						deepHandles.Add("ClientsToVisitCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< ClientsToVisit >) DataRepository.ClientsToVisitProvider.DeepSave,
							new object[] { transactionManager, entity.ClientsToVisitCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<UsersByGpsStocks>
				if (CanDeepSave(entity.UsersByGpsStocksCollection, "List<UsersByGpsStocks>|UsersByGpsStocksCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(UsersByGpsStocks child in entity.UsersByGpsStocksCollection)
					{
						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

					}

					if (entity.UsersByGpsStocksCollection.Count > 0 || entity.UsersByGpsStocksCollection.DeletedItems.Count > 0)
					{
						//DataRepository.UsersByGpsStocksProvider.Save(transactionManager, entity.UsersByGpsStocksCollection);
						
						deepHandles.Add("UsersByGpsStocksCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< UsersByGpsStocks >) DataRepository.UsersByGpsStocksProvider.DeepSave,
							new object[] { transactionManager, entity.UsersByGpsStocksCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<GpsStockByGpsGroups>
				if (CanDeepSave(entity.GpsStockByGpsGroupsCollection, "List<GpsStockByGpsGroups>|GpsStockByGpsGroupsCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(GpsStockByGpsGroups child in entity.GpsStockByGpsGroupsCollection)
					{
						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

						if(child.GpsGroupIdSource != null)
						{
								child.GpsGroupId = child.GpsGroupIdSource.GpsGroupId;
						}

					}

					if (entity.GpsStockByGpsGroupsCollection.Count > 0 || entity.GpsStockByGpsGroupsCollection.DeletedItems.Count > 0)
					{
						//DataRepository.GpsStockByGpsGroupsProvider.Save(transactionManager, entity.GpsStockByGpsGroupsCollection);
						
						deepHandles.Add("GpsStockByGpsGroupsCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< GpsStockByGpsGroups >) DataRepository.GpsStockByGpsGroupsProvider.DeepSave,
							new object[] { transactionManager, entity.GpsStockByGpsGroupsCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<GeoFencesByGpsStock>
				if (CanDeepSave(entity.GeoFencesByGpsStockCollection, "List<GeoFencesByGpsStock>|GeoFencesByGpsStockCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(GeoFencesByGpsStock child in entity.GeoFencesByGpsStockCollection)
					{
						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

						if(child.GeoFenceIdSource != null)
						{
								child.GeoFenceId = child.GeoFenceIdSource.GeoFenceId;
						}

					}

					if (entity.GeoFencesByGpsStockCollection.Count > 0 || entity.GeoFencesByGpsStockCollection.DeletedItems.Count > 0)
					{
						//DataRepository.GeoFencesByGpsStockProvider.Save(transactionManager, entity.GeoFencesByGpsStockCollection);
						
						deepHandles.Add("GeoFencesByGpsStockCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< GeoFencesByGpsStock >) DataRepository.GeoFencesByGpsStockProvider.DeepSave,
							new object[] { transactionManager, entity.GeoFencesByGpsStockCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<Routes>
				if (CanDeepSave(entity.RoutesCollection, "List<Routes>|RoutesCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(Routes child in entity.RoutesCollection)
					{
						if(child.GpsImeiSource != null)
						{
							child.GpsImei = child.GpsImeiSource.GpsImei;
						}
						else
						{
							child.GpsImei = entity.GpsImei;
						}

					}

					if (entity.RoutesCollection.Count > 0 || entity.RoutesCollection.DeletedItems.Count > 0)
					{
						//DataRepository.RoutesProvider.Save(transactionManager, entity.RoutesCollection);
						
						deepHandles.Add("RoutesCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< Routes >) DataRepository.RoutesProvider.DeepSave,
							new object[] { transactionManager, entity.RoutesCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<NotificationsByGps>
				if (CanDeepSave(entity.NotificationsByGpsCollection, "List<NotificationsByGps>|NotificationsByGpsCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NotificationsByGps child in entity.NotificationsByGpsCollection)
					{
						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

						if(child.NotificationIdSource != null)
						{
								child.NotificationId = child.NotificationIdSource.NotificationId;
						}

					}

					if (entity.NotificationsByGpsCollection.Count > 0 || entity.NotificationsByGpsCollection.DeletedItems.Count > 0)
					{
						//DataRepository.NotificationsByGpsProvider.Save(transactionManager, entity.NotificationsByGpsCollection);
						
						deepHandles.Add("NotificationsByGpsCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< NotificationsByGps >) DataRepository.NotificationsByGpsProvider.DeepSave,
							new object[] { transactionManager, entity.NotificationsByGpsCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
	
			#region List<NotificationByGeoFencesByGpsStock>
				if (CanDeepSave(entity.NotificationByGeoFencesByGpsStockCollection, "List<NotificationByGeoFencesByGpsStock>|NotificationByGeoFencesByGpsStockCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(NotificationByGeoFencesByGpsStock child in entity.NotificationByGeoFencesByGpsStockCollection)
					{
						if(child.GpsImeiSource != null)
						{
								child.GpsImei = child.GpsImeiSource.GpsImei;
						}

						if(child.NotificationIdSource != null)
						{
								child.NotificationId = child.NotificationIdSource.NotificationId;
						}

						if(child.UsernameCompanyIdSource != null)
						{
								child.Username = child.UsernameCompanyIdSource.Username;
								child.CompanyId = child.UsernameCompanyIdSource.CompanyId;
						}

						if(child.GeoFenceIdSource != null)
						{
								child.GeoFenceId = child.GeoFenceIdSource.GeoFenceId;
						}

					}

					if (entity.NotificationByGeoFencesByGpsStockCollection.Count > 0 || entity.NotificationByGeoFencesByGpsStockCollection.DeletedItems.Count > 0)
					{
						//DataRepository.NotificationByGeoFencesByGpsStockProvider.Save(transactionManager, entity.NotificationByGeoFencesByGpsStockCollection);
						
						deepHandles.Add("NotificationByGeoFencesByGpsStockCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< NotificationByGeoFencesByGpsStock >) DataRepository.NotificationByGeoFencesByGpsStockProvider.DeepSave,
							new object[] { transactionManager, entity.NotificationByGeoFencesByGpsStockCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region GpsStockChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>GPSTrackingDBV2.Entities.GpsStock</c>
	///</summary>
	public enum GpsStockChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>GpsModels</c> at GpsModelIdSource
		///</summary>
		[ChildEntityType(typeof(GpsModels))]
		GpsModels,
			
		///<summary>
		/// Composite Property for <c>GpsType</c> at GpsTypeIdSource
		///</summary>
		[ChildEntityType(typeof(GpsType))]
		GpsType,
	
		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for ClientsToVisitCollection
		///</summary>
		[ChildEntityType(typeof(TList<ClientsToVisit>))]
		ClientsToVisitCollection,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for GeoFencesCollection_From_GeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<GeoFences>))]
		GeoFenceIdGeoFencesCollection_From_GeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for UsersByGpsStocksCollection
		///</summary>
		[ChildEntityType(typeof(TList<UsersByGpsStocks>))]
		UsersByGpsStocksCollection,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for GpsGroupsCollection_From_GpsStockByGpsGroups
		///</summary>
		[ChildEntityType(typeof(TList<GpsGroups>))]
		GpsGroupIdGpsGroupsCollection_From_GpsStockByGpsGroups,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for NotificationsCollection_From_NotificationByGeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<Notifications>))]
		NotificationIdNotificationsCollection_From_NotificationByGeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for GpsStockByGpsGroupsCollection
		///</summary>
		[ChildEntityType(typeof(TList<GpsStockByGpsGroups>))]
		GpsStockByGpsGroupsCollection,

		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for GeoFencesByGpsStockCollection
		///</summary>
		[ChildEntityType(typeof(TList<GeoFencesByGpsStock>))]
		GeoFencesByGpsStockCollection,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for UsersCollection_From_NotificationByGeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<Users>))]
		UsernameCompanyIdUsersCollection_From_NotificationByGeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for NotificationsCollection_From_NotificationsByGps
		///</summary>
		[ChildEntityType(typeof(TList<Notifications>))]
		NotificationIdNotificationsCollection_From_NotificationsByGps,

		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for RoutesCollection
		///</summary>
		[ChildEntityType(typeof(TList<Routes>))]
		RoutesCollection,

		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for NotificationsByGpsCollection
		///</summary>
		[ChildEntityType(typeof(TList<NotificationsByGps>))]
		NotificationsByGpsCollection,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for GeoFencesCollection_From_NotificationByGeoFencesByGpsStock
		///</summary>
		[ChildEntityType(typeof(TList<GeoFences>))]
		GeoFenceIdGeoFencesCollection_From_NotificationByGeoFencesByGpsStock,

		///<summary>
		/// Collection of <c>GpsStock</c> as ManyToMany for UsersCollection_From_UsersByGpsStocks
		///</summary>
		[ChildEntityType(typeof(TList<Users>))]
		UsernameCompanyIdUsersCollection_From_UsersByGpsStocks,

		///<summary>
		/// Collection of <c>GpsStock</c> as OneToMany for NotificationByGeoFencesByGpsStockCollection
		///</summary>
		[ChildEntityType(typeof(TList<NotificationByGeoFencesByGpsStock>))]
		NotificationByGeoFencesByGpsStockCollection,
	}
	
	#endregion GpsStockChildEntityTypes
	
	#region GpsStockFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;GpsStockColumn&gt;"/> class
	/// that is used exclusively with a <see cref="GpsStock"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class GpsStockFilterBuilder : SqlFilterBuilder<GpsStockColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the GpsStockFilterBuilder class.
		/// </summary>
		public GpsStockFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the GpsStockFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public GpsStockFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the GpsStockFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public GpsStockFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion GpsStockFilterBuilder
	
	#region GpsStockParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;GpsStockColumn&gt;"/> class
	/// that is used exclusively with a <see cref="GpsStock"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class GpsStockParameterBuilder : ParameterizedSqlFilterBuilder<GpsStockColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the GpsStockParameterBuilder class.
		/// </summary>
		public GpsStockParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the GpsStockParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public GpsStockParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the GpsStockParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public GpsStockParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion GpsStockParameterBuilder
	
	#region GpsStockSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;GpsStockColumn&gt;"/> class
	/// that is used exclusively with a <see cref="GpsStock"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class GpsStockSortBuilder : SqlSortBuilder<GpsStockColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the GpsStockSqlSortBuilder class.
		/// </summary>
		public GpsStockSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion GpsStockSortBuilder
	
} // end namespace
